package zmm

import (
	"context"
	"github.com/tiger1103/gfast/v3/api/v1/zmm"
	"github.com/tiger1103/gfast/v3/internal/app/system/controller"
	"github.com/tiger1103/gfast/v3/internal/app/zmm/service"
)

var ZmmEmployee = zmmEmployeeController{}

type zmmEmployeeController struct {
	controller.BaseController
}

// List 列表
func (c *zmmEmployeeController) EmployeeList(ctx context.Context, req *zmm.ZmmEmployeeListReq) (res *zmm.ZmmEmployeeListRes, err error) {
	res = new(zmm.ZmmEmployeeListRes)
	res.Total, res.ZmmEmployee, err = service.ZmmEmployee().GetList(ctx, req)
	return
}

func (c *zmmEmployeeController) EmployeeOpQueryList(ctx context.Context, req *zmm.ZmmEmployeeOpQueryListReq) (res *zmm.ZmmEmployeeListRes, err error) {
	res = new(zmm.ZmmEmployeeListRes)
	res.ZmmEmployee, err = service.ZmmEmployee().GetOpQuery(ctx, req)
	return
}

func (c *zmmEmployeeController) EmployeeEdit(ctx context.Context, req *zmm.ZmmEmployeeEditReq) (res *zmm.ZmmEmployeeEditRes, err error) {
	res = new(zmm.ZmmEmployeeEditRes)
	_, err = service.ZmmEmployee().Edit(ctx, req)
	if err != nil {
		return nil, err
	}
	return
}

func (c *zmmEmployeeController) EmployeeDelete(ctx context.Context, req *zmm.ZmmEmployeeDelReq) (res *zmm.ZmmEmployeeDelRes, err error) {
	res = new(zmm.ZmmEmployeeDelRes)
	err = service.ZmmEmployee().Delete(ctx, req)
	if err != nil {
		return nil, err
	}
	return
}
